const convert = require('koa-connect')
const history = require('connect-history-api-fallback')
const proxy = require('http-proxy-middleware')

module.exports = {
  serve: {
    open: true,
    clipboard: false,
    port: 4002,
    add: (app) => {
      app.use(convert(proxy('/api', {
        target: 'http://jsonplaceholder.typicode.com/',
        changeOrigin: true,
        pathRewrite: { '^/api' : ''}
      })))
      app.use(convert(history()))
    }
  },

  babel: {
    extraPlugins: [
      'babel-plugin-dva-hmr'
    ]
  }
}
